package com.zl.autocode.controller.autocode;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.zl.autocode.controller.base.AutocodeBaseController;
import com.zl.autocode.dto.autocode.keyword.ReqKeywordAddDTO;
import com.zl.autocode.dto.autocode.keyword.ReqKeywordDelDTO;
import com.zl.autocode.dto.autocode.keyword.ReqKeywordDetailDTO;
import com.zl.autocode.dto.autocode.keyword.ReqKeywordEditDTO;
import com.zl.autocode.dto.autocode.keyword.ReqKeywordQueryDTO;
import com.zl.autocode.dto.autocode.keyword.ReqKeywordStateDTO;
import com.zl.autocode.dto.autocode.keyword.ResKeywordAddDTO;
import com.zl.autocode.dto.autocode.keyword.ResKeywordDelDTO;
import com.zl.autocode.dto.autocode.keyword.ResKeywordDetailDTO;
import com.zl.autocode.dto.autocode.keyword.ResKeywordEditDTO;
import com.zl.autocode.dto.autocode.keyword.ResKeywordQueryDTO;
import com.zl.autocode.dto.autocode.keyword.ResKeywordStateDTO;
import com.zl.autocode.service.autocode.IKeywordService;
import com.zl.common.dto.ReqDTO;
import com.zl.common.dto.ResDTO;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 数据库关键字表
 * @author ZL
 */
@Api(value="数据库关键字表",tags ="数据库关键字表")
@RestController("autocodeKeywordController")
@RequestMapping("/autocode/keyword")
public class KeywordController extends AutocodeBaseController {

    @Autowired
    private IKeywordService keywordService;
    
    /**
     * 查询
     */
    @ApiOperation(value="数据库关键字表-查询")
    @RequestMapping(value="/list", method = RequestMethod.POST)
    public ResDTO<ResKeywordQueryDTO> listKeyword(@RequestBody ReqDTO<ReqKeywordQueryDTO> reqInfo) throws Exception{
        ResKeywordQueryDTO data = keywordService.queryKeywordList(reqInfo);
        return successDATA(data);
    }
    
   /**
     * 详情
     */
    @ApiOperation(value="数据库关键字表-详情")
    @RequestMapping(value="/detail", method = RequestMethod.POST)
    public ResDTO<ResKeywordDetailDTO> detailKeyword(@RequestBody ReqDTO<ReqKeywordDetailDTO> reqInfo) throws Exception{
        ResKeywordDetailDTO data = keywordService.queryKeywordDetail(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 新增
     */
    @ApiOperation(value="数据库关键字表-新增")
    @RequestMapping(value="/add", method = RequestMethod.POST)
        public ResDTO<ResKeywordAddDTO> addKeyword(@RequestBody ReqDTO<ReqKeywordAddDTO> reqInfo) throws Exception{
        ResKeywordAddDTO data = keywordService.insertKeywordInfo(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 编辑
     */
    @ApiOperation(value="数据库关键字表-编辑")
    @RequestMapping(value="/edit", method = RequestMethod.POST)
        public ResDTO<ResKeywordEditDTO> editKeyword(@RequestBody ReqDTO<ReqKeywordEditDTO> reqInfo) throws Exception{
        ResKeywordEditDTO data = keywordService.updateKeywordInfo(reqInfo);
        return successDATA(data);
    }
    
    /**
     * 删除
     */
    @ApiOperation(value="数据库关键字表-删除")
    @RequestMapping(value="/del", method = RequestMethod.POST)
        public ResDTO<ResKeywordDelDTO> delKeyword(@RequestBody ReqDTO<ReqKeywordDelDTO> reqInfo) throws Exception{
        ResKeywordDelDTO data = keywordService.deleteKeywordInfo(reqInfo);
        return successDATA(data); 
    }
    
    /**
     * 状态更新
     */
    @ApiOperation(value="数据库关键字表-状态更新")
    @RequestMapping(value="/state", method = RequestMethod.POST)
        public ResDTO<ResKeywordStateDTO> stateKeyword(@RequestBody ReqDTO<ReqKeywordStateDTO> reqInfo) throws Exception{
        ResKeywordStateDTO data = keywordService.updateKeywordState(reqInfo);
        return successDATA(data); 
    }
    
    
}